<template>
	<view>
		<u-waterfall v-if="newList.length!=0" v-model="newList" ref="uWaterfall">
			<template v-slot:left="{leftList}">
				<view class="demo-warter" style="margin-right: 11rpx;" v-for="(item, index) in leftList" :key="index" @click="toPage(item)">
					<!-- 警告：微信小程序中需要hx2.8.11版本才支持在template中结合其他组件，比如下方的lazy-load组件 -->
					<u-lazy-load threshold="0" border-radius="10" :image="item.url?item.url:(resourcesUrlZip + item.resourceId+'_medium.jpeg') " :index="index"></u-lazy-load>
					<view class="demo-title">
						<!-- <view  class="title-tag-tuijian">
							<text style="color: #FFFFFF;font-size: 14rpx;">推荐</text>
						</view> -->
						
						<text class="title-content">
							{{item.name}}
						</text>
					</view>
					<view>
						<!-- <view  class="title-tag-tuijian">
							<text style="color: #FFFFFF;font-size: 14rpx;">推荐</text>
						</view> -->
						
						<text style="font-size: 10px;color: #6A6A6A;">
							<!-- {{item.specification}} -->
							规格：{{item.specification}}
						</text>
					</view>
					<view class="demo-bottom">
						<view v-if="storeShop.id" class="u-flex-col">
							<text class="u-font-9 grey-color">{{item.sellerShopName}}</text>
							<text class="u-font-9 grey-color"
							:class='{"sn-enough":item.inventoryBalance > 9999 ,"sn-not-enough":item.inventoryBalance < item.sellingUnit}'>
								<!-- 库存{{ item.inventoryBalance > 9999?"充足": item.inventoryBalance >= item.sellingUnit ? item.inventoryBalance + item.unit:"不足"}} -->
								{{item.inventoryStatus}}
								</text>
						</view>
						<view v-else></view>
						<view class="bottom-price">
							￥{{ item.price }}
						</view>
					</view>
					<!-- <view class="no-balance-view"  v-if="item.inventoryBalance <= item.sellingUnit&&$store.state.shop.shop.id">
						<image src="/static/home/noBalance.png" mode="" class="no-balance-img"></image>
					</view> -->
					<view class="active-quantity"  v-if="isActive">
						<text>x{{item.quantity}}</text>
					</view>
					
				</view>
			</template>
			<template v-slot:right="{rightList}">
				<view class="demo-warter" style="margin-left: 11rpx;" v-for="(item, index) in rightList" :key="index" @click="toPage(item)">
					<u-lazy-load threshold="0" border-radius="10" :image="item.url " :index="index"></u-lazy-load>
					<view class="demo-title">
						<!-- <view class="title-tag-xinpin">
							<text style="color: #FFFFFF;font-size: 14rpx;">新品</text>
						</view> -->
						<text class="title-content">
							{{item.name}}
						</text>
					</view>
					<view>
						<!-- <view  class="title-tag-tuijian">
							<text style="color: #FFFFFF;font-size: 14rpx;">推荐</text>
						</view> -->
						
						<text style="font-size: 10px;color: #6A6A6A;">
							<!-- {{item.specification}} -->
							规格：{{item.specification}}
						</text>
					</view>
					<view class="demo-bottom">
						<view v-if="storeShop.id" class="u-flex-col">
							<text class="u-font-9 grey-color">{{item.sellerShopName}}</text>
							<text class="u-font-9 grey-color"
							:class='{"sn-enough":item.inventoryBalance > 9999,"sn-not-enough":item.inventoryBalance < item.sellingUnit}'>
								<!-- 库存{{ item.inventoryBalance > 9999?"充足": item.inventoryBalance >= item.sellingUnit ? item.inventoryBalance + item.unit:"不足"}} -->
								{{item.inventoryStatus}}
								</text>
						</view>
						<view v-else></view>
						<view class="bottom-price">
							￥{{ item.price }}
						</view>
					</view>
				<!-- 	<view class="no-balance-view"  v-if="item.inventoryBalance <= item.sellingUnit&&$store.state.shop.shop.id">
						<image src="/static/home/noBalance.png" mode="" class="no-balance-img"></image>
					</view> -->
					<view class="active-quantity"  v-if="isActive">
						<text>x{{item.quantity}}</text>
					</view>
				</view>
			</template>
		</u-waterfall>
		<view class="u-flex-col u-col-center u-row-center" :style="{width: '100%',height:'400rpx'}" v-else>
			<u-empty text="没有可以购买的商品"  ></u-empty>
		</view>
		<u-loadmore :status="loadStatus" v-if="!isActive&&flowList.length!=0"></u-loadmore>
		<u-modal v-model="noShopModal" :content="content" @confirm="goLogin()"></u-modal>				
	</view>
</template>

<script>
	import { useShopStore } from '@/store/shop.js';
	import { mapState } from 'pinia';
	export default {
		data(){
			return {
				noShopModal:false,
				title:"提示",
				content:"请登录后查看",
				
			}
		},
		props: {
			flowList: {
				type: Array,
				default: []
			},
			loadStatus: {
				type: String,
				required: true,
				default: 'loadmore'
			},
			isActive:{
				type: Boolean,
				default: false
			}
		},
		computed: {
			newList: {
				set: function (newV) {
					// this.currentIndex = newV;
				},
				get: function() {
					return this.flowList ? this.flowList : []
				}
			},
			...mapState(useShopStore, {storeShop: 'shop'})
		},
		created(){
				
		},
		methods: {
			// 清空子组件数据
			clear() {
				this.$refs.uWaterfall.clear();
			},
			goLogin(){
				this.$mRouter.push({ route: '/pages/login/index' });
			},
			toPage(item) {
				// 判断是否为用户
				if (!this.storeShop.id) {
					// return this.$mHelper.toOtherApp(item.tmallUrl)
					// this.noShopModal = true;
					this.$mRouter.push({ route: '/pages/index/xiangqing?id=' + item.id })
				}else{
					this.$mRouter.push({ route: '/pages/index/xiangqing?id=' + item.id + '&sellerShopId=' + item.sellerShopId })
				}
			},
			getMoreList() {
				this.$emit('getProductList')
			}
		}
	}
</script>

<style lang="scss" scoped>
	/* 瀑布流 */
	.demo-warter {
		border-radius: 10rpx;
		/* margin: 11rpx; */
		margin-bottom: 20rpx;
		background-color: #ffffff;
		padding: 10rpx;
		box-shadow: 0px 0px 16px 4px rgba(8, 1, 3, 0.1);
		position: relative;
		.no-balance-view{
			position: absolute;
			// width: 100%;
			// height: 100%;
			height: 200rpx;
			width: 200rpx;
			// background-color: rgba(255,255,255,0.6);
			display: flex;
			justify-content: center;
			align-items: center;
			top: 60rpx;
			left: 66rpx;
			.no-balance-img{
				height: 200rpx;
				width: 200rpx;
			}
		}
		.active-quantity{
			position: absolute;
			height: 80rpx;
			width: 80rpx;
			border-radius: 10rpx;
			background-color: #FFBB1A;
			display: flex;
			justify-content: center;
			align-items: center;
			top: 0rpx;
			right: 0rpx;
		}
		
	}
	
	.demo-image {
		width: 100%;
		border-radius: 4px;
	}
	
	.demo-title{
		padding: 0 10rpx;
		font-size: 24rpx;
		margin-top: 19rpx;
		color: $uni-text-color;
		/* vertical-align:middle; */
		.title-tag-tuijian {
			vertical-align:middle;
			display: inline;
			width: 50rpx;
			height: 22rpx;
			// background: linear-gradient(90deg, #0D8DC3, #0CB7FF);
			background: #333333;
			border-radius: 5rpx;
			color: #FFFFFF;
			font-size: 14rpx;
			padding: 5rpx 11rpx;
			margin-right: 10rpx;
		}
		.title-tag-xinpin {
			vertical-align:middle;
			display: inline;
			width: 50rpx;
			height: 22rpx;
			// background-color: linear-gradient(-90deg, #F2730C, #FCB00C);
			background-color: #FF8E30;
			border-radius: 5rpx;
			color: #FFFFFF;
			font-size: 14rpx;
			padding: 5rpx 11rpx;
			margin-right: 10rpx;
		}
		.title-content {
			font-size: 24rpx;
			vertical-align: middle;
		}
	}
	
	.demo-tag {
		display: flex;
		margin-top: 5px;
	}
	
	.demo-tag-owner {
		background-color: $u-type-error;
		color: #FFFFFF;
		display: flex;
		align-items: center;
		padding: 4rpx 14rpx;
		border-radius: 50rpx;
		font-size: 20rpx;
		line-height: 1;
	}
	
	.demo-tag-text {
		border: 1px solid $u-type-primary;
		color: $u-type-primary;
		margin-left: 10px;
		border-radius: 50rpx;
		line-height: 1;
		padding: 4rpx 14rpx;
		display: flex;
		align-items: center;
		border-radius: 50rpx;
		font-size: 20rpx;
	}
	
	.demo-price {
		font-size: 30rpx;
		color: $u-type-error;
		margin-top: 5px;
	}
	
	.demo-bottom {
		padding: 0 10rpx;
		margin-top: 16rpx;
		display: flex;
		justify-content: space-between;
		align-items:flex-end;
		.bottom-shop {
			vertical-align: middle;
			color: #999999;
			font-size: 18rpx;
			margin-right: 30rpx;
		}
		.bottom-price {
			font-size: 34rpx;
			color: $uni-text-color;
		}
	}
</style>
